package com.henry.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.henry.dao.entity.SysTplPconfig;
import com.henry.dao.mapper.SysTplPconfigMapper;
import com.henry.service.SysTplPconfigService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.beans.BeanUtils;
import com.henry.web.vo.Response;
import com.henry.web.vo.SysTplPconfigRequestBean;
import java.util.List;

/**
 * <p>
 *   服务实现类
 * </p>
 *
 * @author zhenggui.wu
 * @email 237891668@qq.com
 * @date 2017-06-01 15:08:59
 */
@Service
public class SysTplPconfigServiceImpl extends ServiceImpl<SysTplPconfigMapper, SysTplPconfig> implements SysTplPconfigService {

    private Logger logger= LoggerFactory.getLogger(SysTplPconfigServiceImpl.class);

    @Override
    public List<SysTplPconfig> findAllSysTplPconfig(SysTplPconfigRequestBean sysTplPconfigRequestBean) {
        SysTplPconfig sysTplPconfig=new SysTplPconfig();
        BeanUtils.copyProperties(sysTplPconfigRequestBean,sysTplPconfig);
        EntityWrapper<SysTplPconfig> war=new EntityWrapper();
        war.setEntity(sysTplPconfig);
        return this.selectList(war);
    }

    @Override
    public Response saveSysTplPconfig(SysTplPconfigRequestBean sysTplPconfigRequestBean) {
        Response response=new Response();
        try {
            SysTplPconfig sysTplPconfig=new SysTplPconfig();
            BeanUtils.copyProperties(sysTplPconfigRequestBean,sysTplPconfig);
            this.insert(sysTplPconfig);
            response.setSuccess();
        }catch (Exception e){
            logger.info(e.getMessage(),e);
            response.setFail();
        }
        return response;
    }

    @Override
    public Response updateSysTplPconfig(SysTplPconfigRequestBean sysTplPconfigRequestBean) {
        Response response=new Response();
        try {
            SysTplPconfig sysTplPconfig=new SysTplPconfig();
            BeanUtils.copyProperties(sysTplPconfigRequestBean,sysTplPconfig);
            this.updateById(sysTplPconfig);
            response.setSuccess();
        }catch (Exception e){
            logger.info(e.getMessage(),e);
            response.setFail();
        }
        return response;
    }



    @Override
    public Response deleteSysTplPconfig(Integer id) {
        Response response=new Response();
        try {
            this.deleteById(id);
            response.setSuccess();
        }catch (Exception e){
            logger.info(e.getMessage(),e);
            response.setFail();
        }
        return response;
    }

}
